﻿using UnityEngine;
using System.Collections;

public class MB_CustomSceneObject : BM_LevelObject {

	private bool m_ambience = true;
	private float time = 0.0f;
	private float targetTime = 0.0f;

	public AudioSource bg_ambience;
	public AudioSource bg_music;
	public AudioSource sfx_jingle;

	public override void Update() {

		if(m_ambience) {
			time += Time.deltaTime;
			if(time > targetTime) {
				bg_ambience.Play();
				targetTime = Random.Range(0, 5);
				time = 0;
			}
		}
			
		if(m_rMessageHandler.ReceivedMessageWithID(MessageID.MSGID_QUEST_DRAGONSLAYER_ACTIVATION) != null) {
			Debug.Log ("PLAY");
			if(!bg_music.isPlaying)
				bg_music.Play();
			m_ambience = false;
		}
		else if(m_rMessageHandler.ReceivedMessageWithID(MessageID.MSGID_QUEST_DRAGONSLAYER_RESCUED) != null) {
			sfx_jingle.Play();
		}
	}

}
